package com.yanqu.road.server.cmd.activity.flowercard;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FlowerCardsProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.flowercard.FlowerCardsModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.flowercard.FlowerCardsConfig;
import com.yanqu.road.server.manger.activity.flowercard.FlowerCardsMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_FLOWER_CARDS_GET_USER_DATA, desc = "获取玩家数据")
public class FlowerCardsGetUserDataCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        // 没有活动
        FlowerCardsConfig config = FlowerCardsMgr.getConfig();
        if (config == null || !ActivityMgr.activityInShowTime(config.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        ret = player.getModule(FlowerCardsModule.class).getUserDataReq();
    }

    @Override
    public void sendData(GamePlayer player) {

        if(ret != 0){
            player.sendPacket(Protocol.U_FLOWER_CARDS_GET_USER_DATA, FlowerCardsProto.FlowerCardsGetUserDataRespMsg.newBuilder().setRet(ret));
        }

    }
}
